<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>列出所有有效数据库</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongoclient.killcursor.html">MongoClient::killCursor</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongoclient.selectcollection.html">MongoClient::selectCollection</a></div>
 <div class="up"><a href="class.mongoclient.html">MongoClient</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mongoclient.listdbs" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoClient::listDBs</h1>
  <p class="verinfo">(PECL mongoclient &gt;=1.0.4)</p><p class="refpurpose"><span class="refname">MongoClient::listDBs</span> &mdash; <span class="dc-title">列出所有有效数据库</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongoclient.listdbs-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">array</span> <span class="methodname"><strong>MongoClient::listDBs</strong></span>
    ( <span class="methodparam">void</span>
   )</div>

 </div>


 <div class="refsect1 parameters" id="refsect1-mongoclient.listdbs-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongoclient.listdbs-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回的关联数组包括了三个字段。
   第一个字段是 <em>databases</em>，里面包含了一个数组。每个元素对应一个数据库，给出数据库名称、尺寸以及是否为空。
   另外两个字段是
   <em>totalSize</em>（单位为字节 bytes）和 <em>ok</em>，如果方法成功运行，它会是 1。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-mongoclient.listdbs-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-1376">
   <p><strong>Example #1 <span class="methodname"><strong>MongoClient::listDBs()</strong></span> 例子</strong></p>
   <div class="example-contents"><p>
    例子演示了如何列出数据库，并返回数据的结构。
   </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$mongo&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoClient</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$dbs&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$mongo</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">listDBs</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbs</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [databases] =&gt; Array
        (
            [0] =&gt; Array
                (
                    [name] =&gt; doctrine
                    [sizeOnDisk] =&gt; 218103808
                    [empty] =&gt;
                )
        )

    [totalSize] =&gt; 218103808
    [ok] =&gt; 1
)

</pre></div>
   </div>
  </div>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongoclient.killcursor.html">MongoClient::killCursor</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongoclient.selectcollection.html">MongoClient::selectCollection</a></div>
 <div class="up"><a href="class.mongoclient.html">MongoClient</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
